﻿Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Windows.Forms


Public Class WriteLogFile
    Public Sub WriteLogFile(ByVal fileName As String, ByVal methodName As String, ByVal message As String)
        Dim cesta As String = System.Web.HttpContext.Current.Server.MapPath("../LogFiles/")
        Try
            If message <> "" Then
                Using file As New FileStream(cesta + String.Format("Log_{0}.txt", Format(Now, "ddMMyyyy")), FileMode.Append, FileAccess.Write)
                    Dim streamWriter As New StreamWriter(file)
                    streamWriter.WriteLine((((System.DateTime.Now & " - ") + fileName & " - ") + methodName & " - ") + message)
                    streamWriter.Close()
                    file.Close()
                End Using
            End If
        Catch
        End Try
    End Sub
End Class
